#!/usr/bin/env python
import sys
import os
from HandleMysql import *
import glob
reload(sys)
sys.setdefaultencoding('utf-8')

def writeTextToFile(path,fileName,mode,content):
    try:
        if not os.path.exists(path):
            os.makedirs(path)
        #print '------------',path    
        f=open(path+os.path.sep+fileName,mode)
        f.write(content)
        f.close()
        return True
    except Exception,e:
        print e
        return False
    finally:
        pass

def remove_file(file_path):
    if os.path.isfile(file_path): 
        os.remove(file_path)

    
def load_data(conn,path,table_name,split):    
    load_sql="LOAD DATA LOCAL INFILE '%s' INTO TABLE %s  FIELDS TERMINATED BY '%s' LINES TERMINATED BY '\n'"%(path,table_name,split)
    #print load_sql
    conn.execute_sql(load_sql)
    
    